-- @owner: cr13
-- @date: 2023-05-16
-- @testpoint: opengauss关键字admin(非保留)，作为触发器名，合理报错

--step1:创建源表 expect:成功
drop table if exists test_trigger_src_tbl;
create table test_trigger_src_tbl(id1 INT, id2 INT, id3 INT);

--step2:创建触发器函数 expect:成功
create or replace function tri_insert_func() returns trigger as  $$
declare
begin
    insert into test_trigger_des_tbl VALUES(NEW.id1, NEW.id2, NEW.id3);
    return new;
end
$$ language plpgsql;
/

--step3:创建INSERT触发器不带引号 expect:创建成功
drop trigger if exists alias on test_trigger_src_tbl;
create trigger alias before insert on test_trigger_src_tbl for each row execute procedure tri_insert_func();
/

--step4:创建INSERT触发器带双引号 expect:创建成功
drop trigger if exists "alias" on test_trigger_src_tbl;
create trigger "alias" before insert on test_trigger_src_tbl for each row execute procedure tri_insert_func();
/

--step5:创建INSERT触发器带单引号 expect:合理报错
drop trigger if exists 'alias' on test_trigger_src_tbl;
create trigger 'alias' before insert on test_trigger_src_tbl for each row execute procedure tri_insert_func();
/

--step6:创建INSERT触发器带反单引号 expect:合理报错
drop trigger if exists `admin` on test_trigger_src_tbl;
create trigger `admin` before insert on test_trigger_src_tbl for each row execute procedure tri_insert_func();
/

--step7:清理环境 expect:成功
drop trigger if exists alias on test_trigger_src_tbl;
drop function tri_insert_func;
drop table if exists test_trigger_src_tbl;